package com.woniuxy.activiti.controller;

import com.woniuxy.entity.User;
import com.woniuxy.service.UserService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author xilei
 * @create 2021--15 11:38
 */
@RestController
public class UserController {

    @Resource
    private UserService userService;

    /**
     * 查询所有用户列表
     * @return
     */
    @GetMapping("/user/findAll")
    public List<User> findUserList(){
        System.out.println("123");
        List<User> userList = userService.all();
        System.out.println("321");
        return userList;
    }

    /**
     * 查询单个用户根据id去查
     * @param userid
     * @return
     */
    @GetMapping("/user/findOne/{id}")
    public User findUserList(@PathVariable(name = "id") int userid){
        User user = userService.getUser(userid);
        return user;
    }

}
